package com.wchen.gdoc.generate.resource.analysis;

import com.sun.javadoc.Type;
import com.wchen.gdoc.generate.config.ApplicationConfigProvide;
import com.wchen.gdoc.generate.resource.structure.FieldStructure;
import com.wchen.gdoc.generate.util.DataTypeUtil;


/**
 * 基本类型解析器
 *
 * @author  wchen
 * @date    2019/11/7
 */
public class BaseTypeDocAnalysis extends AbsParentAnalysis implements DocTypeAnalysis {

    @Override
    public Boolean isSupport(Type docType) {
        return DataTypeUtil.isBaseData(docType.qualifiedTypeName());
    }

    @Override
    public FieldStructure analysisParam(Type docType, Boolean isRequestParam) {
        if(ENABLE_DEBUG) {
            LOGGER.info(String.format("execute BaseTypeDocAnalysis, docType=%s", docType.qualifiedTypeName()));
        }
        FieldStructure typeStructure = new FieldStructure();
        //基本类型转成包装类型
        String transType = DataTypeUtil.getTransType(docType.qualifiedTypeName());
        typeStructure.setType(transType);
        typeStructure.setSimpleName(docType.simpleTypeName());
        return typeStructure;
    }
}
